package com.qbw.app.module.vehicle.holder;

import android.content.Context;
import android.view.ViewGroup;

import com.qbw.app.R;
import com.qbw.app.databinding.VehicleHolderProblemItemBinding;
import com.qbw.app.model.Problem;
import com.qbw.app.module.common.holder.CommonHolder;
import com.qbw.app.module.vehicle.VehicleDataBindingAdapter;
import com.qbw.core.base.BaseHolder;

/**
 * @author QBW
 * @date 2019-08-24
 */
public class VehicleProblemItemHolder extends CommonHolder<Problem, VehicleHolderProblemItemBinding> {

    public VehicleProblemItemHolder(Context context, ViewGroup viewParent) {
        super(context, R.layout.vehicle_holder_problem_item, viewParent);
    }

    @Override
    public void bindData(int position, Problem data) {
        super.bindData(position, data);
        mBinding.tvDesc.setText(data.getFaultCodeDec());
        if (data.getStartTime() > 0) {
            VehicleDataBindingAdapter.setVehicleProglemHistoryTime(mBinding.tvTime,
                                                                   data.getStartTime(),
                                                                   data.getEndTime());
        } else if (data.getAultTime() > 0) {
            VehicleDataBindingAdapter.setVehicleProblemUpdateTime(mBinding.tvTime,
                                                                  data.getAultTime());
        }
    }
}
